package com.example.pptls;

import android.os.Bundle;
import android.app.Activity;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.view.Menu;
import android.widget.TextView;

public class SQLdatos extends Activity {

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_sqldatos);
		
		
		TextView txt = (TextView)findViewById(R.id.datosSql);
		SqlDatabase usdbh = new SqlDatabase(this, "DBUsuarios", null, 1);
		 
        SQLiteDatabase db = usdbh.getWritableDatabase();
 
		Cursor cursor = db.rawQuery("SELECT * FROM Records", null);
		int i=0;
		cursor.moveToFirst();
		do{
			
			String user1 = cursor.getString(0);
			String user2 = cursor.getString(1);
			String ganador = cursor.getString(2);
			
			txt.setText(user1+" " +user2+ " "+ganador);
			i++;
		}while (i<5 && cursor.moveToNext());
	}

	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		// Inflate the menu; this adds items to the action bar if it is present.
		getMenuInflater().inflate(R.menu.sqldatos, menu);
		return true;
	}

}
